package com.cxf.windex.task;

import com.cxf.windex.biz.WeiTypeBiz;
import com.cxf.windex.dto.Types;
import com.cxf.windex.entity.WeiType;
import com.cxf.windex.entity.WeiUser;
import java.util.concurrent.Future;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

/**
 * @author chenxf
 * @date 4/22/2018
 * @description
 */
@Component
public class TypeTask {
  public static final Logger logger = LoggerFactory.getLogger(TypeTask.class);
  @Autowired
  private WeiTypeBiz weiTypeBiz;

  @Async
  public Future<String> doTypeTask(String[] types,String typesName)  {
   for(String typeName:types){
     WeiType type=new WeiType();
     type.setName(typeName);
     type.setCode(typesName);
     if(weiTypeBiz.selectOne(type)==null && StringUtils.isNotBlank(typeName)){
       weiTypeBiz.insertSelective(type);
     }
   }
    return new AsyncResult<>("标签插入完成");
  }

}
